using System;

using Microsoft.Practices.Prism.Modularity;
using Microsoft.Practices.Prism.Regions;
using Microsoft.Practices.Unity;

using StudentModule.Views;
using StudentModule.Services;
using Infrastructure;

namespace StudentModule
{
    public class ModuleInit : IModule
    {
        private readonly IUnityContainer container;
        private readonly IRegionManager regionManager;

        public ModuleInit(IUnityContainer container, IRegionManager regionManager)
        {
            this.container = container;
            this.regionManager = regionManager;
        }

        #region IModule Members

        public void Initialize()
        {
            // Register the DataService concrete type with the container.
            // The DataService's lifetime is controlled by the container so
            // a single instance is created and shared across the application.
            // Change this to swap in another data service implementation.
            container.RegisterType<IDataService, DataService>(new ContainerControlledLifetimeManager());

            // Display the View in the Shell. Uses Prism's 'View
            // Discovery' mechanism to automatically display the view
            // in the specified named region.
            //_regionManager.RegisterViewWithRegion(RegionNames.NavigationRegion, () => _container.Resolve<StudentManagerNavGroupView>());

            this.regionManager.RegisterViewWithRegion(RegionNames.MenuRegion, () => container.Resolve<StudentManagerMenuView>());
            //this.regionManager.RegisterViewWithRegion(RegionNames.ContentRegion, () => container.Resolve<SearchSinhVienView>());
            // Register the view types with the container so that it can create them
            // during navigation. Note that the container will attempt to create the
            // view as a named object so the views have to be registered as such.
            container.RegisterType<Object, View1>("View1");
        }

        #endregion
    }
}
